Skip to content

Mimic autosave in Scratch Editor#1469

Open
abcampo-iry wants to merge 4 commits into
mainfrom
issues/1212-autosave
Open

Mimic autosave in Scratch Editor#1469
abcampo-iry wants to merge 4 commits into
mainfrom
issues/1212-autosave

Conversation

@abcampo-iry
Copy link
Copy Markdown
Contributor

@abcampo-iry abcampo-iry commented May 14, 2026

This change adds autosave for Scratch projects and keeps the behaviour close to the existing Python and HTML editors.

Python and HTML already autosave after a short delay when the user owns a saved project. Scratch is different because project changes happen inside the Scratch iframe, so we listen to Scratch VM change events and pass those changes back to the main app.

Autosave only starts once the Scratch project has been saved or remixed and has an identifier. New Scratch projects, and projects that need to be remixed first, still show the manual Save button. After that first save/remix, the manual Save button is hidden and the header shows the autosave status instead.

The autosave delay is 2 seconds. If a save is already running, we do not start another one immediately; we queue the next autosave until the current save finishes.

Scratch save events now update the shared Redux editor save state: saving, lastSavedTime, and lastSaveAutosave. This is the same state used by the existing save status UI, so Scratch can reuse SaveStatus instead of keeping a separate local save-status flow in the Scratch hook.

The Scratch save/remix tests have also been updated to cover the new flow: first save/remix, identifier update, hiding the manual Save button, and triggering autosave once the project is eligible.

As Teacher:

Screen.Recording.2026-05-15.at.15.57.12.mov

As Student (first time):

Screen.Recording.2026-05-15.at.15.58.36.mov

@abcampo-iry abcampo-iry temporarily deployed to previews/1469/merge May 14, 2026 16:23 — with GitHub Actions Inactive
@abcampo-iry abcampo-iry force-pushed the issues/1212-autosave branch from 637b154 to 6a84bbe Compare May 15, 2026 12:49
@abcampo-iry abcampo-iry temporarily deployed to previews/1469/merge May 15, 2026 12:50 — with GitHub Actions Inactive
@abcampo-iry abcampo-iry force-pushed the issues/1212-autosave branch from 6a84bbe to d6b7a86 Compare May 15, 2026 13:07
@abcampo-iry abcampo-iry temporarily deployed to previews/1469/merge May 15, 2026 13:07 — with GitHub Actions Inactive
@abcampo-iry abcampo-iry force-pushed the issues/1212-autosave branch from d6b7a86 to 0da7d2b Compare May 15, 2026 13:14
@abcampo-iry abcampo-iry temporarily deployed to previews/1469/merge May 15, 2026 13:14 — with GitHub Actions Inactive
@abcampo-iry abcampo-iry force-pushed the issues/1212-autosave branch from 0da7d2b to dbfdb88 Compare May 15, 2026 13:49
@abcampo-iry abcampo-iry temporarily deployed to previews/1469/merge May 15, 2026 13:50 — with GitHub Actions Inactive
@abcampo-iry abcampo-iry force-pushed the issues/1212-autosave branch from dbfdb88 to 1145479 Compare May 15, 2026 14:12
@abcampo-iry abcampo-iry temporarily deployed to previews/1469/merge May 15, 2026 14:12 — with GitHub Actions Inactive
@abcampo-iry abcampo-iry force-pushed the issues/1212-autosave branch from 1145479 to b205bb8 Compare May 15, 2026 14:14
@abcampo-iry abcampo-iry marked this pull request as ready for review May 15, 2026 14:14
@abcampo-iry abcampo-iry temporarily deployed to previews/1469/merge May 15, 2026 14:14 — with GitHub Actions Inactive
Copilot AI review requested due to automatic review settings May 15, 2026 14:14
@abcampo-iry abcampo-iry changed the title Issues/1212 autosave Mimic autosave in Scratch Editor May 15, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds Scratch autosave by forwarding Scratch VM change events from the iframe to the main editor and reusing the shared Redux save-status state/UI.

Changes:

  • Adds Scratch save lifecycle Redux actions and tests.
  • Updates Scratch save hooks and project bar behavior to hide manual Save once autosave is eligible.
  • Adds Scratch iframe change-event forwarding and updates unit/Cypress coverage for the new autosave flow.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/redux/EditorSlice.js Adds Scratch-specific save state actions.
src/redux/EditorSlice.test.js Covers Scratch save timestamp and lifecycle reducers.
src/hooks/useScratchSaveState.js Implements Scratch autosave scheduling and save message handling.
src/hooks/useScratchSaveState.test.js Tests autosave debounce, queueing, and Redux state updates.
src/hooks/useScratchSave.js Enables autosave only for eligible Scratch projects.
src/components/ScratchEditor/ScratchIntegrationHOC.jsx Emits project-changed events from Scratch VM changes/uploads.
src/components/ScratchEditor/ScratchIntegrationHOC.test.jsx Tests Scratch VM project-changed event forwarding.
src/components/ProjectBar/ScratchProjectBar.jsx Switches saved Scratch projects from manual Save to SaveStatus.
src/components/ProjectBar/ScratchProjectBar.test.js Tests Scratch save button/status/autosave behavior.
cypress/e2e/spec-scratch.cy.js Updates Scratch remix flow E2E coverage for autosave.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/hooks/useScratchSaveState.js
Comment thread src/hooks/useScratchSaveState.js Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.

Comment thread src/components/ProjectBar/ScratchProjectBar.jsx
@adrian-rpf
Copy link
Copy Markdown
Contributor

I see no issues but due to the impact of this change should have an another engineer review.

non-blocking: We should discuss how we are handling the auto-save time. See Thread .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants